package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.User;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class UserDTO extends User implements Converter<User, UserDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    private Date startDate;

    private Date endDate;

    private String[] roleIds;

    @Override
    public void convert2Do(User user) {
        BeanUtils.copyProperties(this, user);
    }

    @Override
    public UserDTO convert(User user) {
        BeanUtils.copyProperties(user, this);
        return this;
    }
}
